{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 2,
   "id": "initial_id",
   "metadata": {
    "collapsed": true,
    "ExecuteTime": {
     "end_time": "2025-06-07T04:22:48.890111400Z",
     "start_time": "2025-06-07T04:22:48.816827600Z"
    }
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "AUC: 0.8633504859919954\n"
     ]
    }
   ],
   "source": [
    "from sklearn.preprocessing import LabelEncoder\n",
    "from sklearn.metrics import roc_auc_score, classification_report\n",
    "import pandas as pd\n",
    "import joblib\n",
    "from src.zzm.config.config import FEATURE_NAMES\n",
    "\n",
    "import os\n",
    "os.chdir(r'E:\\project\\python\\brain_drain_predict_project')\n",
    "# 读取数据\n",
    "data = pd.read_csv(\"data/raw/test2.csv\")\n",
    "# 数据预处理  将有多分类的列 转化为 数值型的\n",
    "label_encoder = LabelEncoder()\n",
    "data = data.apply(label_encoder.fit_transform)\n",
    "# 提取特征和标签\n",
    "X = data[FEATURE_NAMES]\n",
    "scale = joblib.load('scale_model.pkl')\n",
    "X = scale.transform(X)\n",
    "y = data[\"Attrition\"]\n",
    "\n",
    "# 加载模型\n",
    "model = joblib.load('xgb_model.pkl')\n",
    "y_pred = model.predict_proba(X)[:, 1]\n",
    "\n",
    "# 评估模型 AUC: 0.8627787307032591\n",
    "print(\"AUC:\", roc_auc_score(y, y_pred))\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "outputs": [],
   "source": [],
   "metadata": {
    "collapsed": false
   },
   "id": "5b8cb0b42ba49c51"
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 2
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython2",
   "version": "2.7.6"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 5
}
